package com.everflourish.yeah100.utils;

import java.util.Stack;

import android.app.Activity;

/**
 * 应用的activity堆栈类
 * 
 * @author pf
 * @date 2014-11-19
 */
public class SystemApp {
	private static SystemApp mInstance;
	private Stack<Activity> statck = new Stack<Activity>();

	private SystemApp() {
	}

	public synchronized static SystemApp getInstance() {
		if (mInstance == null) {
			mInstance = new SystemApp();
		}
		return mInstance;
	}

	// 添加Activity到堆栈中
	public void addStack(Activity activity) {
		statck.add(activity);// 添加Activity到堆栈中
	}

	// 把Activity移出堆栈
	public void delActivity(Activity activity) {
		statck.remove(activity);
	}

	public void exitSystem() {
		for (Activity activity : statck) {
			if (activity != null) {
				activity.finish();// 销毁
			}
		}
	}
}
